# -*- coding: utf-8 -*-
from pymongo import Connection
import gridfs

def parse_mongodb_options(config):
    ret = {}
    ret['url'] = config.get("mongodb.url", r'mongodb://127.0.0.1:27017/')
    return ret

def parse_gridfs_options(config):
    ret = {}
    ret['container'] = config.get('gridfs.container', 'gridfs')
    return ret


def make_mongodb_connection(url):
    return Connection(host=url)

def make_gridfs_connection(conn, container):
    return lambda collection: gridfs.GridFS(conn[container], collection=collection)
